package com.code2roc.jarmanage.servlet.machine;

import com.alibaba.fastjson.JSONObject;
import com.code2roc.jarmanage.model.MachineCPUInfo;
import com.code2roc.jarmanage.model.MachineMemoryInfo;
import com.code2roc.jarmanage.model.Result;
import com.code2roc.jarmanage.util.MachineUtil;
import com.code2roc.jarmanage.util.StringUtil;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


public class MachineRefreshServelt extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Result result = Result.okResult();
        MachineCPUInfo cpuInfo = MachineUtil.getMachineCPUInfo();
        MachineMemoryInfo memoryInfo = MachineUtil.getMachineMemoryInfo();
        result.add("loadRatio", cpuInfo.getLoadRatio());
        result.add("useRatio", memoryInfo.getUseRatio());
        resp.getWriter().println(result.toString());
    }
}
